home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright (C) 1991 Texas Instruments Incorporated.
- //
- // Permission is granted to any individual or institution to use, copy, modify,
- // and distribute this software, provided that this complete copyright and
- // permission notice is maintained, intact, in all copies and supporting
- // documentation.
- //
- // Texas Instruments Incorporated provides this software "as is" without
- // express or implied warranty.
- //
- //
- // Created: MBN 09/01/89 -- Initial design and implementation
- // Updated: LGO 12/04/89 -- Efficiency re-write
- // Updated: MJF 03/12/90 -- Added group names to RAISE
- // Updated: MJF 07/31/90 -- Added terse print
- // Updated: DLS 03/27/91 -- New lite version
- //
- // The CoolRange class implements non-type specific common functionality for the
- // parameterized CoolRange<Type>. In this manner, code replication is reduced. The
- // CoolRange<Type> class supports arbitrary user-defined ranges for a type of
- // object or built-in data type. This allows other higher level data structures
- // such as Vector to be parameterized over a range of values for some type so
- // that the programmer does not have to add bounds checking code to the
- // application. A Vector of positive integers, for example, would be easy to
- // declare, facilitating bounds checking restricted to the code that implements
- // the type, not the vector.
- //
- // The inclusive upper and lower bounds for the range are stored in two private
- // static data slots for the class as a whole. In addition, a single instance
- // private data slot holds the instance value. There are three constructors.
- // The first is a simple empty constructor. The second is a constructor that
- // also accepts an initial value. And the third is a constructor that takes a
- // reference to another CoolRange<Type> object and copies the value.
- //
- // All methods are implemented as small inline functions to provide efficient
- // encapsulation of objects, including built-in types such as int. Methods are
- // provided to set and get the lower and upper bounds for the class as a whole
- // and set the value of the instance data slot. Assignment of one object to
- // another is supported by the overloaded operator= methods. Operator() is an
- // inline method to return the value of the instance object. Finally, an
- // implicit conversion from a CoolRange<Type> object to a Type value is provided to
- // allow for mixed expressions.
- //
-
- #ifndef BASE_RANGEH // If no CoolRange class
- #include <cool/Base_Range.h> // Include header file
- #endif
-
-
- // set_low_error -- Raise exception for CoolRange::set() constructor
- // Input: Character string indicating type and value
- // Output: None
-
- void CoolRange::set_low_error (const char* type, const char* lbound, const char* hbound,
- const char* value) const {
- //RAISE (Error, SYM(CoolRange), SYM(Under_Lower_Limit),
- printf ("CoolRange<%s,%s,%s>::set(): Value %s less than lower-limit", type, lbound, hbound, value);
- }
-
-
- // set_upper_error -- Raise exception for CoolRange::set() constructor
- // Input: Character string indicating type and value
- // Output: None
-
- void CoolRange::set_upper_error (const char* type, const char* lbound, const char* hbound, const char* value) const {
- //RAISE (Error, SYM(CoolRange), SYM(Over_Upper_Limit),
- printf ("CoolRange<%s,%s,%s>::set(): Value %s greater than upper-limit", type, lbound, hbound, value);
- }
-
-
- // print -- terse print function for CoolRange
- // Input: reference to output stream
- // Output: none
-
- void CoolRange::print(ostream& os) {
- os << form("/* CoolRange %lx */", (long) this);
- }
-
-
-
-